package hc.bre.policy

import hc.bre.cmn.IListOption
import hc.bre.cmn.ListOption

@groovy.transform.CompileStatic
@groovy.transform.ToString(includeNames=true,includePackage=false)
class CheckResultReason implements Comparable<CheckResultReason>{
	@com.fasterxml.jackson.annotation.JsonIgnore
	IListOption reason;
	@com.fasterxml.jackson.annotation.JsonIgnore
	CategoryOption category;

	public CategoryOption getCategory() {
		return category?:_nullCategory;
	}

	static public final CategoryOption _nullCategory = new CategoryOption(id:0,code:'',name:'',level:0) ;

	@Override
	public int compareTo(CheckResultReason o) {
		return this.getCategory().level - o.category.level;
	}

	public int getReasonId() {
		return reason.getId();
	}

	public String getReasonCode() {
		return reason.getCode();
	}

	public String getReasonName() {
		return reason.getName();
	}

	public Integer getCategoryId() {
		return getCategory().getId();
	}

	public String getCategoryCode() {
		return getCategory().getCode();
	}

	public String getCategoryName() {
		return getCategory().getName();
	}

	public Integer getCategoryLevel() {
		return getCategory().getLevel();
	}
}